package com.drama.api.task;

import cn.hutool.core.util.IdUtil;
import com.drama.api.company.message.dao.CompanyMessageDao;
import com.drama.api.company.message.domain.po.CompanyMessagePO;

import java.util.Date;

public class CompanyMessageThread extends Thread {

    private CompanyMessageDao companyMessageDao;

    private String companyId;

    private String msgTitle;

    private String msgDesc;

    private String msgUrl;

    private Integer msgType;

    private String userId;

    public CompanyMessageThread(CompanyMessageDao companyMessageDao,String companyId,String msgTitle,String msgDesc,String msgUrl,Integer msgType,String userId){
        this.companyMessageDao=companyMessageDao;
        this.companyId=companyId;
        this.msgTitle=msgTitle;
        this.msgDesc=msgDesc;
        this.msgUrl=msgUrl;
        this.msgType=msgType;
        this.userId=userId;
    }

    @Override
    public void run() {
        CompanyMessagePO companyMessagePO=new CompanyMessagePO();
        companyMessagePO.setId(IdUtil.getSnowflakeNextIdStr());
        companyMessagePO.setCreateBy(userId);
        companyMessagePO.setUpdateBy(userId);
        companyMessagePO.setCreateDate( new Date());
        companyMessagePO.setUpdateDate(companyMessagePO.getCreateDate());
        companyMessagePO.setCompanyId(companyId);
        companyMessagePO.setMsgState(2);
        companyMessagePO.setMsgTitle(msgTitle);
        companyMessagePO.setMsgDesc(msgDesc);
        companyMessagePO.setMsgType(msgType);
        companyMessagePO.setMsgUrl(msgUrl);
        companyMessagePO.setDelFlag(Boolean.FALSE);
        companyMessageDao.insertSelective(companyMessagePO);
    }
}
